﻿using System;

namespace _5E.Utils.MathHelper
{
    public static class RandomHelper
    {
        #region 静态属性

        public static Random Instance
        {
            get
            {
                var seed = Guid.NewGuid().GetHashCode();
                var rd = new Random(seed);
                return rd;
            }
        }

        #endregion

        #region 静态方法

        public static Int32 GetRandomInt32(Int32 max, Int32 min = 0)
        {
            var num = 0;
            if (max < min)
            {
                throw new ArgumentException("最大值不能小于最小值!");
            }
            else if (max == min)
            {
                num = max;
            }
            else
            {
                var rd = Instance;
                num = rd.Next(min, max);
            }
            return num;
        }

        #endregion
    }
}
